home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Carteles-Metropoli (ES).ifs < prev    next >
Text File  |  2005-03-13  |  9KB  |  289 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=micmic (micmic@dieznet.com)
  8. Title=Carteles-Metropoli
  9. Description=Picture importation script for carteles-metropoli
  10. Site=carteles.metropoliglobal.com 
  11. Language=ES
  12. Version=1.0
  13. Requires=3.5.0
  14. Comments=
  15. License=The source code of the script can be used in another program only if full credits to script author and a link to Ant Movie Catalog website are given in the About box or in the documentation of the program.|
  16. GetInfo=1
  17.  
  18. [Options]
  19. TitleMixedCase=0|0|0=Each letter of each word of title begins with Uppercase|1=Titles in lowercase except first letter of first word
  20.  
  21. ***************************************************) 
  22.  
  23. program micmic;
  24. var
  25.   MovieName: string;
  26. const
  27.   Base = 'http://carteles.metropoliglobal.com/';
  28.   BaseURL = 'http://carteles.metropoliglobal.com/4resultados.php?titulo=';
  29.   BaseURL2 = '&director=&interpretes=&Submit=Buscar';
  30.  
  31. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  32. var
  33.   i: Integer;
  34. begin
  35.   result := -1;
  36.   if StartAt < 0 then
  37.     StartAt := 0;
  38.   for i := StartAt to List.Count-1 do
  39.     if Pos(Pattern, List.GetString(i)) <> 0 then
  40.     begin
  41.       result := i;
  42.       Break;
  43.     end;
  44. end;
  45.  
  46. function AnalizaBigImagePage(ImagenURL: string): string;
  47. var
  48.   Page: TStringList;
  49.   LineNr: Integer;
  50.   PosIni, PosFin: Integer;
  51.   Line, SubLine: string;
  52.   txtTemp: string;
  53. begin
  54.   Page := TStringList.Create;
  55.   Page.Text := GetPage(ImagenURL);
  56.  
  57.   txtTemp := '<td bgcolor="#FFFFFF"><div align="center"><img src="';
  58.   LineNr := FindLine(txtTemp, Page, 0);
  59.   if LineNr > 0 then
  60.   begin
  61.     Line := Page.GetString(LineNr);
  62.  
  63.     PosIni := pos(txtTemp, Line);
  64.     SubLine := Copy(Line, PosIni + Length(txtTemp), Length(Line));
  65.  
  66.     txtTemp := '"';
  67.     PosFin := pos(txtTemp, SubLine);
  68.  
  69.     txtTemp := Copy(SubLine, 1, PosFin - 1);
  70.   end else
  71.     txtTemp := '';
  72.    
  73.   Page.Free;
  74.  
  75.   result := txtTemp;
  76. end;
  77.  
  78. procedure AnalyzePage(Address: string);
  79. var
  80.   Page: TStringList;
  81.   LineNr: Integer;
  82.   PosIni, PosFin: Integer;
  83.   Line, SubLine: string;
  84.   Title, DirURL: string;
  85.   txtTemp: string;
  86. begin
  87.   Page := TStringList.Create;
  88.   Page.Text := GetPage(Address);
  89.   if Pos('No se han encontrado resultados', Page.Text) > 0 then
  90.   begin
  91.     ShowMessage('No se ha encontrado ning·n artφculo por tφtulo.');
  92.   end else
  93.   begin
  94.     PickTreeClear;
  95.     PickTreeAdd('Resultados para "' + MovieName + '" en ' + Base + ':', '');
  96.    
  97.     // buscamos los resultados
  98.     LineNr := 0;
  99.  
  100.     while LineNr < Page.Count do
  101.     begin
  102.       SubLine := Page.GetString(LineNr);
  103.       txtTemp := '<td width="92%"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="';
  104.       PosIni := pos(txtTemp, SubLine);
  105.       if PosIni > 0 then
  106.       begin
  107.         SubLine := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  108.        
  109.         txtTemp := '">';
  110.         PosFin := pos(txtTemp, SubLine);
  111.         DirURL := Base + Copy(SubLine, 1, PosFin - 1);
  112.        
  113.         SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine));
  114.         txtTemp := '</a>';
  115.         PosFin := pos(txtTemp, SubLine);
  116.         Title := Copy(SubLine, 1, PosFin - 1);
  117.  
  118.         //ShowMessage(Title + '-->' + DirURL);
  119.         PickTreeAdd(Title, DirURL);
  120.       end;
  121.       LineNr := LineNr + 1;
  122.     end;
  123.  
  124.     Page.Free;
  125.     if PickTreeExec(Address) then
  126.       AnalyzeMoviePage(Address);
  127.   end;
  128. end;
  129.  
  130. procedure AnalyzeMoviePage(Address: string);
  131. var
  132.   Page: TStringList;
  133.   PosIni, PosFin: Integer;
  134.   dirBase: string;
  135.   txtTemp: string;
  136.   txtAux: string;
  137.   campo, valor: string;
  138.   LineNr: Integer;
  139.   Line, SubLine: string;
  140.   ImagenPeqSRC, ImagenURL, ImagenGrandeSRC: string;
  141.   Comentarios: string;
  142. begin
  143.   //ShowMessage(Address);
  144.  
  145.   SetField(fieldURL, Address);
  146.  
  147.   Page := TStringList.Create;
  148.   Page.Text := StringReplace(GetPage(Address), '<br>', #13#10);
  149.  
  150.   // buscamos los campos
  151.   Comentarios := '';
  152.   ImagenPeqSRC := '';
  153.   ImagenURL := '';
  154.   ImagenGrandeSRC := '';
  155.   LineNr := 0;
  156.   while LineNr < Page.Count do
  157.   begin
  158.     SubLine := Page.GetString(LineNr);
  159.    
  160.     //txtTemp := '<title>';
  161.     txtTemp := '<img src="galeriaforo/images/rating';
  162.     PosIni := pos(txtTemp, SubLine);
  163.     if PosIni > 0 then
  164.     begin
  165.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  166.       PosFin := pos('.', txtAux);
  167.       campo := Copy(txtAux, 1, PosFin - 1);
  168.       if campo <> '' then SetField(fieldRating, campo);
  169.     end;
  170.    
  171.     txtTemp := '<td width="68%" valign="TOP" bgcolor="#F5F5F5"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
  172.     PosIni := pos(txtTemp, SubLine);
  173.     if PosIni > 0 then
  174.     begin
  175.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  176.       PosFin := pos('</font></td>', txtAux);
  177.       campo := Copy(txtAux, 1, PosFin - 1);
  178.       if campo <> '' then SetField(fieldOriginalTitle, campo);
  179.     end;
  180.    
  181.     txtTemp := '<td valign="TOP" bgcolor="#FFFFFF"><div align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
  182.     PosIni := pos(txtTemp, SubLine);
  183.     if PosIni > 0 then
  184.     begin
  185.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  186.       PosFin := pos(':', txtAux);
  187.       campo := Copy(txtAux, 1, PosFin - 1);
  188.  
  189.       LineNr := LineNr + 2;
  190.       SubLine := Page.GetString(LineNr);
  191.       txtTemp := '<td valign="TOP" bgcolor="#F5F5F5"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
  192.       PosIni := pos(txtTemp, SubLine);
  193.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  194.       PosFin := pos('</font></td>', txtAux);
  195.       valor := Copy(txtAux, 1, PosFin - 1);
  196.  
  197.       if campo = 'AÑO' then SetField(fieldYear, valor);
  198.       if campo = 'NACIONALIDAD' then SetField(fieldCountry, valor);
  199.       if campo = 'DIRECTOR' then SetField(fieldDirector, valor);
  200.       if campo = 'INTÉRPRETES' then SetField(fieldActors, valor);
  201.  
  202.       if campo = 'DURACION' then Comentarios := Comentarios + 'Duraci≤n: ' + valor + #13#10;
  203.       if campo = 'GUIÓN' then Comentarios := Comentarios + 'Gui≤n: ' + valor + #13#10;
  204.       if campo = 'FOTOGRAFÍA' then Comentarios := Comentarios + 'Fotografφa: ' + valor + #13#10;
  205.       if campo = 'MÚSICA' then Comentarios := Comentarios + 'M·sica: ' + valor + #13#10;
  206.  
  207.       //ShowMessage(campo + '-->' + valor);
  208.     end;
  209.    
  210.     txtTemp := '/cpp/albums/userpics/';
  211.     PosIni := pos(txtTemp, SubLine);
  212.     if PosIni > 0 then
  213.     begin
  214.       txtAux := Copy(SubLine, PosIni, Length(SubLine));
  215.       PosFin := pos('" width="', txtAux);
  216.       campo := Copy(txtAux, 1, PosFin - 1);
  217.       if ImagenPeqSRC = '' then ImagenPeqSRC := Base + campo;
  218.     end;
  219. //this is the other directory I found
  220.     txtTemp := '/c/';
  221.     PosIni := pos(txtTemp, SubLine);
  222.     if ((PosIni > 0) and (ImagenPeqSRC = '')) then
  223.     begin
  224.       txtAux := Copy(SubLine, PosIni, Length(SubLine));
  225.       PosFin := pos('" width="', txtAux);
  226.       campo := Copy(txtAux, 1, PosFin - 1);
  227.       if ImagenPeqSRC = '' then ImagenPeqSRC := Base + campo;
  228.     end;
  229.    
  230.     //now the big image
  231.     txtTemp := 'pgrande.php?image_id=';
  232.     PosIni := pos(txtTemp, SubLine);
  233.     if ((PosIni > 0) and (ImagenURL = '')) then
  234.     begin
  235.       txtAux := Copy(SubLine, PosIni, Length(SubLine));
  236.       PosFin := pos('">', txtAux);
  237.       campo := Copy(txtAux, 1, PosFin - 1);
  238.       if ImagenURL = '' then ImagenURL := Base + campo;
  239.     end;
  240.  
  241.     txtTemp := '<td valign="TOP" colspan="2"><font size="1" face="Arial, Helvetica, sans-serif">';
  242.     PosIni := pos(txtTemp, SubLine);
  243.     if PosIni > 0 then
  244.     begin
  245.       txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
  246.       PosFin := pos('</font></td>', txtAux);
  247.       campo := Copy(txtAux, 1, PosFin - 1);
  248.       if campo <> '' then SetField(fieldDescription, campo);
  249.     end;
  250.    
  251.     LineNr := LineNr + 1;
  252.   end;
  253.  
  254.   if Comentarios <> '' then SetField(fieldComments, Comentarios);
  255.  
  256.   if ImagenURL <> '' then ImagenGrandeSRC := Base + AnalizaBigImagePage(ImagenURL);
  257.  
  258.   //ShowMessage(ImagenGrandeSRC + '<--' + ImagenPeqSRC);
  259.  
  260.   If (ImagenGrandeSRC <> '') or (ImagenPeqSRC <> '') then
  261.   begin
  262.     PickTreeClear;
  263.     PickTreeAdd('Imagenes para  "' + MovieName + '" en ' + Base + ':', '');
  264.  
  265.     If (ImagenPeqSRC <> '') then PickTreeAdd('Peque±a', ImagenPeqSRC);
  266.     If (ImagenGrandeSRC <> '') then PickTreeAdd('Grande', ImagenGrandeSRC);
  267.  
  268.     if PickTreeExec(Address) then GetPicture(Address);
  269.  
  270.   end;
  271.  
  272.   Page.Free;
  273.   //DisplayResults;
  274. end;
  275.  
  276. // bmicmic: Bucle Principal
  277. begin
  278.   if CheckVersion(3,5,0) then
  279.   begin
  280.     MovieName := GetField(fieldOriginalTitle);
  281.     if MovieName = '' then
  282.       MovieName := GetField(fieldTranslatedTitle);
  283.     Input('Importar de ' + Base, 'Introduce el Titulo de la Pelicula:', MovieName);
  284.     AnalyzePage(BaseURL + UrlEncode(MovieName) + BaseURL2);
  285.    
  286.   end else
  287.        ShowMessage('Este script necesita una versi≤n superior de Ant Movie Catalog (al menos la version 3.5.0)');
  288. end.
  289.